//
//  ATMCashDefines.h
//

#import <Foundation/Foundation.h>

#if (ADHOC > 0 || DEBUG > 0)
#    define DLog(fmt, ...) NSLog((@"%s #%d " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#    define DLog(...)
#endif


#pragma mark Notification key

extern float DimensionBaseIphone6(float aHeight);

#define kNotificationMsg_Land_Sucess     @"kNotificationMsg_Land_Sucess"
#define kNotificationMsg_Exit_Success    @"kNotificationMsg_Exit_Success"


#define singleton_interface(className) + (className *)shared##className;

#define singleton_implementation(className) \
static id  _instance;  \
+ (id)shared##className  \
{   \
if (_instance == nil) { \
_instance = [[self alloc] init];    \
}   \
return _instance;   \
}   \
+ (id)allocWithZone:(struct _NSZone *)zone  \
{   \
static dispatch_once_t once;    \
dispatch_once(&once, ^{ \
_instance = [super allocWithZone:zone]; \
}); \
return _instance;   \
}

#define kScreenWidth      [UIScreen mainScreen].bounds.size.width
#define kScreenHeight     [UIScreen mainScreen].bounds.size.height

#define IS_IPhoneX_All (kScreenHeight == 812.f || kScreenHeight == 844.f || kScreenHeight == 896.f || kScreenHeight == 926.f || kScreenHeight == 932.f || kScreenHeight == 852.f)

#define kHeight_StatusBar [NSObject vg_statusBarHeight]

#define kHeight_NavBar 44.0f

#define kNavigationBarHeight  (kHeight_StatusBar + kHeight_NavBar)

#define kHeight_TabBar (IS_IPhoneX_All ? 83.0f:49.0f)

#define kHeight_BottomSafe (IS_IPhoneX_All? 34.0f:0.0f)

#define kGeneralHeight    44.0

#define PMStringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] == 0 )


#define PMObjectIsEmpty(_object) (_object == nil \
|| [_object isKindOfClass:[NSNull class]] \
|| ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
|| ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))


#define kWeakSelf __weak typeof (self) weakSelf = self;
#define kStrongSelf __strong __typeof(&*weakSelf)strongSelf = weakSelf;
#define kWeakObj(obj)  __weak typeof(obj) weakObj = obj;
#define __es_weak        __weak
#define es_weak_property weak

#define ESWeak(var, weakVar) __weak __typeof(&*var) weakVar = var
#define ESStrong_DoNotCheckNil(weakVar, _var) __typeof(&*weakVar) _var = weakVar
#define ESStrong(weakVar, _var) ESStrong_DoNotCheckNil(weakVar, _var); if (!_var) return;

#define ESWeak_(var) ESWeak(var, weak_##var);
#define ESStrong_(var) ESStrong(weak_##var, _##var);

/** defines a weak `self` named `__weakSelf` */
#define ESWeakSelf      ESWeak(self, __weakSelf);
/** defines a strong `self` named `_self` from `__weakSelf` */
#define ESStrongSelf    ESStrong(__weakSelf, _self);

/*
 color
 */
#define RGB(r, g, b)        [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1.0f]
#define RGBA(r, g, b, a)    [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:a]

#define kArcRandomColor   [UIColor colorWithRed:arc4random() %255 /255.0f green:arc4random() %255 /255.0f blue:arc4random() %255 /255.0f alpha:1.0f]

#define HexRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
 
#define kButtonRedColor             RGB(0,186,96)//[UIColor colorWithHexString:@"#DB5249"]

#define kTableViewBackColor         [UIColor colorWithHexString:@"#F7F7F7"]

#define kLineColor                  [UIColor colorWithHexString:@"#F1F3F2"]

#define kBlackColor                 [UIColor colorWithHexString:@"#191919"]

#define kFuturaMedium               @"Futura-Medium"
#define kFuturaMediumItalic         @"Futura-MediumItalic"
#define kFuturaBold                 @"Futura-Bold"
#define kFuturaCondensedMedium      @"Futura-CondensedMedium"
#define kFuturaCondensedExtraBold   @"Futura-CondensedExtraBold"
#define kFuturaBTMedium             @"FuturaBT-Medium"
#define kFuturaBTBook               @"FuturaBT-Book"
#define kFuturaBT                   @"FuturaBT"
#define kFutura                     @"Futura"

#define kIsNeedLocation             @"kIsNeedLocation"

#define kCOLOR_CHANGE_COLOR         @[(__bridge id)[UIColor colorWithHexString:@"#E6673E"].CGColor,(__bridge id)[UIColor colorWithHexString:@"#DB5249"].CGColor]
#define kCOLOR_BTNCOLOR_CHANGE      @[(__bridge id)[UIColor colorWithHexString:@"#E6673E"].CGColor,(__bridge id)[UIColor colorWithHexString:@"#DB5249"].CGColor]

#define kBACK_SHADOWCOLOR           [UIColor colorWithHexString:@"#000000" alpha:0.75f]

#define kUserPhoneStr  @"kUserPhoneStr"

typedef void (^VoidBlock)(void);


NS_INLINE BOOL ESIsStringWithAnyText(id object) {
    return ([object isKindOfClass:[NSString class]] && ![(NSString *)object isEqualToString:@""]);
}


typedef void (^ESErrorBlock)(NSError *error);
typedef void (^ESHandlerBlock)(id sender);

#define ES_EXTERN extern
ES_EXTERN void ESDispatchSyncOnMainThread(dispatch_block_t block);
ES_EXTERN void ESDispatchAsyncOnMainThread(dispatch_block_t block);
ES_EXTERN void ESDispatchOnGlobalQueue(dispatch_queue_priority_t priority, dispatch_block_t block);
ES_EXTERN void ESDispatchOnDefaultQueue(dispatch_block_t block);
ES_EXTERN void ESDispatchOnHighQueue(dispatch_block_t block);
ES_EXTERN void ESDispatchOnLowQueue(dispatch_block_t block);
ES_EXTERN void ESDispatchOnBackgroundQueue(dispatch_block_t block);
ES_EXTERN void ESDispatchAfter(NSTimeInterval delayTime, dispatch_block_t block);


#define kScheme                     @"mmla://mmla.ios.app"
#define kIsMmlaAppHome              [NSString stringWithFormat:@"%@%@",kScheme,@"/koalaIrisTan"]
#define kIsMmlaAppLogin             [NSString stringWithFormat:@"%@%@",kScheme,@"/iceWatermelo"]
#define kIsMmlaAppOrder             [NSString stringWithFormat:@"%@%@",kScheme,@"/hibiscusOnio"]
#define kIsMmlaAppOrderDetail       [NSString stringWithFormat:@"%@%@",kScheme,@"/kaleXylophon"]
#define kIsMmlaAppChangeBankCard    [NSString stringWithFormat:@"%@%@",kScheme,@"/elephantVani"]

#define kDefaultTabBarFixHeight (IS_IPhoneX_All ? 0 : 25)

#define kNeedRefreshOrderDetNotification   @"kNeedRefreshOrderDetNotification"


#define kWLTitleStr        @"Are you sure you want to bypass verification of this information?"
#define kWLDescStr         @"Completing authentication will increase your chances of loan approval!"

#define kHomeIDFA         @"kHomeIDFA"
#define kLoginIDFA        @"kLoginIDFA"

#define kRecordLastTime   @"kRecordLastTime"

#define kCityDataAry      @"kCityDataAry"
#define kOrderNumber      @"kOrderNumber"

#define kMakemoneya       @"makemoneya"
#define kMakemoneyb       @"makemoneyb"
#define kMakemoneyc       @"makemoneyc"
#define kMakemoneyd       @"makemoneyd"
#define kMakemoneye       @"makemoneye"
#define kMakemoneyf       @"makemoneyf"
#define kMakemoneyg       @"makemoneyg"
#define kMakemoneyh       @"makemoneyh"
#define kMakemoneyi       @"makemoneyi"
#define kMakemoneyj       @"makemoneyj"
#define kMakemoneyk       @"makemoneyk"
#define kMakemoneyl       @"makemoneyl"
#define kMakemoneym       @"makemoneym"



#define kLongitude        @"kLongitude"
#define kLatitude         @"kLatitude"
#define kEatStr           @"kEatStr"
#define kOfficersStr      @"kOfficersStr"
#define kSoldiersStr      @"kSoldiersStr"
#define kEarningStr       @"kEarningStr"
#define kStarvedStr       @"kStarvedStr"

#define kIDFAStr          @"kIDFAStr"
#define kAppLaunchTime    @"kAppLaunchTime"


#define kRecStartTime     @"kRecStartTime"
#define kRecEndTime       @"kRecEndTime"
